
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadSignature
from django.conf import settings
def get_verify_url(id,email):
    if not all(['id,email']):
        raise Exception('id,email不能为空')

    s = Serializer(settings.SECRET_KEY,3600)


    token = s.dumps({
        'id':'id',
        'email':'email'
    })

    url = 'http://meiduo.site:8000/success_verify_email.html?token=' + token.decode()
    return url

def check_verify_token(token):

    s = Serializer(settings.SECRET_KEY, 3600)

    try:
       result = s.loads(token)

    except BadSignature:
        return None
    else:
        return result.get('id')